package com.nm.utils;

import com.nm.commons.exception.ErrorsDispatcher;
import com.nm.commons.exception.SupperException;

import java.util.Collection;
import java.util.List;

/**
 * Created by hewu on 2017/2/9 0009.
 */
public class AssertSupport {

    /**
     * 判断对象是否为空
     *
     * @param t
     * @param e
     * @throws SupperException
     */
    public static void isNullObject(Object t, ErrorsDispatcher e) throws SupperException {
        if (t == null) {
            throw e.e();
        }
    }

    /**
     * 是否是空字符串
     *
     * @param str
     * @param e
     * @throws SupperException
     */
    public static void isNullStr(String str, ErrorsDispatcher e) throws SupperException {
        if (str == null || str.length() == 0) {
            throw e.e();
        }
    }

    /**
     * 是否是空集合/数组
     *
     * @param collection
     * @param e
     * @throws SupperException
     */
    public static void isNullList(List list, ErrorsDispatcher e) throws SupperException {
        if (null == list || list.size() == 0) {
            throw e.e();
        }
    }


}
